/********************************************/
// Creation History
// --------------------------------------------------------------
//	Company:		HTSZ
//	NAME:			EmployeeUpdate.java
//    Title   :		Update Staff Last Date
//	FUNCTION:
//	BY:				Beyes Xia
//	DATE:			2004-07-06 15:48
// --------------------------------------------------------------
/*********************************************/
/*--------------------------------------------------------------
 Amend record
 Date          Version         Author          Description
 06/07/2004    1.0             Beyes           Create for log 1304.
 ---------------------------------------------------------------*/

package tss.employee;

import java.sql.Connection;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import tss.common.DBServlet2;

import com.ffpc.struts.StrutsMessage;
import com.util.JdbcUtil;

/**
 * A Class class.
 * <P>
 * 
 * @author HTHK
 */
public class EmployeeUpdate extends DBServlet2 {
	private Logger logger = Logger.getLogger(EmployeeUpdate.class);

	@Override
	protected String perform(HttpServletRequest request,
			HttpServletResponse response, StrutsMessage message)

	{

		String lastDate = "";
		String staffNo = request.getParameter("staff_no");

		if (request.getParameter("last_date") != null)
			lastDate = request.getParameter("last_date");

		logger.debug("lastDate=" + lastDate);
		logger.debug("staffNo=" + staffNo);
		Connection con = null;
		Statement stmt = null;
		try {
			con = this.getConnection();
			stmt = con.createStatement();

			String sql = " update tss.tss_c_employee set last_date = to_date('"
					+ lastDate + "','YYYY/MM/DD') ";
			sql += " where staff_no = '" + staffNo + "' ";

			logger.debug("sql:" + sql);

			stmt.executeUpdate(sql);
			return "tss/employee/EmployeeSave.jsp?flag=Y&staffNo=" + staffNo;
		} catch (Exception e) {
			logger.error(e,e);
			return "tss/employee/EmployeeSave.jsp?flag=N&staffNo=" + staffNo;
		} finally {
			JdbcUtil.release(stmt);
		}
	}
}
